#pragma once

#include <stdio.h>
#include <vector>
#include <time.h>
#include <string>

std::string GetMonthName(int month)
{
    std::vector<std::string> months = {"Jan", "Feb", "Mar",
                                       "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    return months[month];
}
std::string GetWeekDayName(int day)
{
    std::vector<std::string> weekdays = {"Sun", "Mon", "Tue",
                                         "Wed", "Thu", "Fri", "Sat"};
    return weekdays[day];
}
std::string ExpireTimeUseRfc1123(int t) // 秒级别的未来 UTC 时间
{
    time_t timeout = time(nullptr) + t;
    // 这个地方有坑哦
    struct tm *tm = gmtime(&timeout); // 这里不能用 localtime，
    char timebuffer[1024];
    // 时间格式如: expires=Thu, 18 Dec 2024 12:00:00 UTC
    snprintf(timebuffer, sizeof(timebuffer),
    "expires=%s, %02d %s %d %02d:%02d:%02d UTC",
    GetWeekDayName(tm->tm_wday).c_str(),
    tm->tm_mday,
    GetMonthName(tm->tm_mon).c_str(),
    tm->tm_year+1900,
    tm->tm_hour,
    tm->tm_min,
    tm->tm_sec);

    return timebuffer;

}